<?php

use yii\db\Migration;

class m210222_144707_common_config_value extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%common_config_value}}', [
            'id' => "int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键'",
            'app_id' => "varchar(20) NOT NULL DEFAULT '' COMMENT '应用'",
            'config_id' => "int(10) NOT NULL DEFAULT '0' COMMENT '配置id'",
            'merchant_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '商户id'",
            'data' => "text NULL COMMENT '配置内'",
            'PRIMARY KEY (`id`)'
        ], "ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COMMENT='公用_配置值表'");
        
        /* 索引设置 */
        $this->createIndex('config_id','{{%common_config_value}}','config_id',0);
        
        
        /* 表数据 */
        $this->insert('{{%common_config_value}}',['id'=>'1','app_id'=>'backend','config_id'=>'6','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'2','app_id'=>'backend','config_id'=>'1','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'3','app_id'=>'backend','config_id'=>'60','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'4','app_id'=>'backend','config_id'=>'59','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'5','app_id'=>'backend','config_id'=>'4','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'6','app_id'=>'backend','config_id'=>'2','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'7','app_id'=>'backend','config_id'=>'5','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'8','app_id'=>'backend','config_id'=>'7','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'9','app_id'=>'backend','config_id'=>'52','merchant_id'=>'0','data'=>'1']);
        $this->insert('{{%common_config_value}}',['id'=>'10','app_id'=>'backend','config_id'=>'55','merchant_id'=>'0','data'=>'9']);
        $this->insert('{{%common_config_value}}',['id'=>'11','app_id'=>'backend','config_id'=>'53','merchant_id'=>'0','data'=>'1']);
        $this->insert('{{%common_config_value}}',['id'=>'12','app_id'=>'backend','config_id'=>'90','merchant_id'=>'0','data'=>'0']);
        $this->insert('{{%common_config_value}}',['id'=>'13','app_id'=>'backend','config_id'=>'64','merchant_id'=>'0','data'=>'1']);
        $this->insert('{{%common_config_value}}',['id'=>'14','app_id'=>'backend','config_id'=>'61','merchant_id'=>'0','data'=>'1']);
        $this->insert('{{%common_config_value}}',['id'=>'15','app_id'=>'backend','config_id'=>'40','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'16','app_id'=>'backend','config_id'=>'41','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'17','app_id'=>'backend','config_id'=>'42','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'18','app_id'=>'backend','config_id'=>'43','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'19','app_id'=>'backend','config_id'=>'44','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'20','app_id'=>'backend','config_id'=>'45','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'21','app_id'=>'backend','config_id'=>'46','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'22','app_id'=>'backend','config_id'=>'47','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'23','app_id'=>'backend','config_id'=>'65','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'24','app_id'=>'backend','config_id'=>'66','merchant_id'=>'0','data'=>'0']);
        $this->insert('{{%common_config_value}}',['id'=>'25','app_id'=>'backend','config_id'=>'75','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'26','app_id'=>'backend','config_id'=>'76','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'27','app_id'=>'backend','config_id'=>'77','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'28','app_id'=>'backend','config_id'=>'78','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'29','app_id'=>'backend','config_id'=>'79','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'30','app_id'=>'backend','config_id'=>'80','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'31','app_id'=>'backend','config_id'=>'81','merchant_id'=>'0','data'=>'0']);
        $this->insert('{{%common_config_value}}',['id'=>'32','app_id'=>'backend','config_id'=>'87','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'33','app_id'=>'backend','config_id'=>'112','merchant_id'=>'0','data'=>'http']);
        $this->insert('{{%common_config_value}}',['id'=>'34','app_id'=>'backend','config_id'=>'8','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'35','app_id'=>'backend','config_id'=>'9','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'36','app_id'=>'backend','config_id'=>'10','merchant_id'=>'0','data'=>'4']);
        $this->insert('{{%common_config_value}}',['id'=>'37','app_id'=>'backend','config_id'=>'11','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'38','app_id'=>'backend','config_id'=>'12','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'39','app_id'=>'backend','config_id'=>'13','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'40','app_id'=>'backend','config_id'=>'14','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'41','app_id'=>'backend','config_id'=>'16','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'42','app_id'=>'backend','config_id'=>'17','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'43','app_id'=>'backend','config_id'=>'19','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'44','app_id'=>'backend','config_id'=>'54','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'45','app_id'=>'backend','config_id'=>'114','merchant_id'=>'0','data'=>'0']);
        $this->insert('{{%common_config_value}}',['id'=>'46','app_id'=>'backend','config_id'=>'116','merchant_id'=>'0','data'=>'0']);
        $this->insert('{{%common_config_value}}',['id'=>'47','app_id'=>'backend','config_id'=>'115','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'48','app_id'=>'backend','config_id'=>'126','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'49','app_id'=>'backend','config_id'=>'127','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'50','app_id'=>'backend','config_id'=>'68','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'51','app_id'=>'backend','config_id'=>'69','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'52','app_id'=>'backend','config_id'=>'70','merchant_id'=>'0','data'=>'']);
        $this->insert('{{%common_config_value}}',['id'=>'53','app_id'=>'backend','config_id'=>'71','merchant_id'=>'0','data'=>'']);
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%common_config_value}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

